/*
 * Copyright © 2017 eqxiu.com 北京中网易企秀科技有限公司  All rights reserved.
 */
package cn.hermit.data.json.handler;

import cn.hermit.data.json.JSON;

/**
 * JSON streaming API in SAX syntax
 * 
 * @author Jack Gao (Chinese name : GAO JIANGUO, Email : linux.gjg@gmail.com)
 * @date 18 Jun, 2014
 */
public interface ContentHandler {
	
	/**
	 * Invoked when the parser walks in JSON document.
	 */
	void startDocument();

	/**
	 * Invoked when the parser walks into sub JSON Object.
	 * 
	 * @param inArray
	 * 		<p>
	 * 		If true, it says the parser just walked from a JSON Array into a sub JSON Object.
	 * 		Otherwise, the parser just walked from a JSON Object into a sub JSON Object.
	 * 		</p> 
	 */
	void startObject(boolean inArray);

	/**
	 * Invoked when the parser walks into a JSON Key in JSON Entry.
	 * @see JSON#STATUS_ENTRY JSON Entry
	 * 
	 * @param key
	 * 		JSON key
	 */
	void key(String key);

	/**
	 * Invoked when the parser walks into sub JSON Array.
	 * 
	 * @param inArray
	 * 		<p>
	 * 		If true, it says the parser just walked from a JSON Array into a sub JSON Array.
	 * 		Otherwise, the parser just walked from a JSON Object into a sub JSON Array.
	 * 		</p> 
	 */
	void startArray(boolean inArray);

	
	/**
	 * Invoked when the parser walks into a JSON Value in JSON Entry.
	 * @see JSON#STATUS_ENTRY JSON Entry
	 * 
	 * @param value
	 * 		JSON Value
	 * @param isText
	 * 		<p>
	 * 		If true, that means the value is primitive.
	 * 		Otherwise, the value is a string.
	 * 		</p>
	 * @param inArray
	 * 		<p>
	 * 		If true, that means the value in a JSON Array.
	 * 		Otherwise, the value is in a JSON Object.
	 * 		</p>
	 */
	void value(String value, boolean isText,boolean inArray);

	/**
	 * Invoked when the parser walks out of a JSON Array
	 * 
	 * @param inArray
	 * 		<p>
	 * 		If true, the parser walk back to a JSON Array after walking out of a sub JSON Array.
	 * 		Otherwise, the parser walk back to a JSON Object after walking out of a sub JSON Array.
	 * 		</p>
	 */
	void endArray(boolean inArray);

	/**
	 * Invoked when the parser walks out of a JSON Object
	 * 
	 * @param inArray
	 * 		<p>
	 * 		If true, the parser walk back to a JSON Array after walking out of a sub JSON Object.
	 * 		Otherwise, the parser walk back to a JSON Object after walking out of a sub JSON Object.
	 * 		</p>
	 */
	void endObject(boolean inArray);
	
	/**
	 * Invoke when the parser finished walking in JSON Document.
	 */
	void endDocument();

}